Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the codebase’s Python bindings from pybind11 to nanobind in order to leverage its smaller footprint and improved ABI stability.
- Update project dependencies and build configuration in pyproject.toml
- Replace pybind11 includes, macros, and APIs with their nanobind equivalents in all binding source files
- Adjust tests and submodules to accommodate the nanobind syntax and usage
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Updated dependencies and build-system to use nanobind |
| cpp/evalio/types.h | Minor cleanup; removal of a redundant comment |
| cpp/evalio/bindings.h | Migrated binding definitions from pybind11 to nanobind with NB macros |
| cpp/bindings/types.h | Revised bindings and API calls for types using nanobind syntax |
| cpp/bindings/ros_pc2.h | Updated nanobind-based bindings for ROS point cloud conversions |
| cpp/bindings/pipelines/bindings.h | Adjusted pipeline bindings to use nanobind macros and functions |
| cpp/bindings/main.cpp | Replaced PYBIND11_MODULE with NB_MODULE and updated related includes |
Files not reviewed (2)
- CMakeLists.txt: Language not supported
- cpp/bindings/CMakeLists.txt: Language not supported
Owner
Author
|
Another nicety, nanobind comes with builtin stub generation! |
Owner
Author
|
Finally got stubs added in and working with tests. Also, verified that the wheel made on the github action runner (ubuntu 24.04 gcc) had an identical ABI to my system (ubuntu 20.04 gcc) and worked properly with evalio-example. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This switches from pybind11 to nanobind, which is a smaller, more modern successor by the same author as pybind11. It should improve compile and runtimes slightly according to their benchmarks.
I've been planning on making this switch eventually, but what prompted it now is how nanobind stabilizes across C++ ABIs. Currently, to use external pybind11 modules (think adding custom gtsam factor python bindings that work with gtsam python bindings, or adding your own evalio pipeline in your own codebase) requires your codebase to be compiled with nearly the exact same compiler and libstdc++ version as the python package. This is obviously hard to do when distributing python wheels.
This PR fixes this, by loosening to only require the same libstdc++ version which should be easier to our users to match when implementing their own custom pipeline. There isn't currently a pybind11 release with this merged PR, but there is a nanobind one!
Migration is pretty easy, with mostly renaming of things required.
I still need to test whether this helps things or not.